﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;
using System.Data;
using System.Data.SqlClient;
using Maticsoft.DBUtility;

public partial class ReportD : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnViewReport_Click(object sender, EventArgs e)
    {
        try
        {
            string StartTime = tbStartTime.Text;
            string EndTime = tbEndTime.Text;

            if (string.IsNullOrEmpty(StartTime))
            {
                StartTime = "200001";
            }

            if (string.IsNullOrEmpty(EndTime))
            {
                EndTime = "209912";
            }

            this.ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
            LocalReport localReport = ReportViewer1.LocalReport;
            localReport.ReportPath = "Reports/Emp3/ReportD.rdlc";
            localReport.DataSources.Clear();

            // 按所属指挥中心分组
            DataSet ds1 = new DataSet();
            SqlParameter[] para1 = {new SqlParameter("@StartTime",StartTime)
                                 ,new SqlParameter("@EndTime",EndTime)
                                  };
            ds1 = DbHelperSQL.ExecProc("uspEmp3ReportD1", para1);
            ReportDataSource rds1 = new ReportDataSource();
            rds1.Name = "DataSet1";
            rds1.Value = ds1.Tables[0];
            localReport.DataSources.Add(rds1);

            //按城市分组
            DataSet ds2 = new DataSet();
            SqlParameter[] para2 = {new SqlParameter("@StartTime",StartTime)
                                 ,new SqlParameter("@EndTime",EndTime)
                                  };
            ds2 = DbHelperSQL.ExecProc("uspEmp3ReportD2", para2);
            ReportDataSource rds2 = new ReportDataSource();
            rds2.Name = "DataSet2";
            rds2.Value = ds2.Tables[0];
            localReport.DataSources.Add(rds2);

            //按入职年限分组
            DataSet ds3 = new DataSet();
            SqlParameter[] para3 = {new SqlParameter("@StartTime",StartTime)
                                 ,new SqlParameter("@EndTime",EndTime)
                                  };
            ds3 = DbHelperSQL.ExecProc("uspEmp3ReportD3", para3);
            ReportDataSource rds3 = new ReportDataSource();
            rds3.Name = "DataSet3";
            rds3.Value = ds3.Tables[0];
            localReport.DataSources.Add(rds3);

            //按职级分组
            DataSet ds4 = new DataSet();
            SqlParameter[] para4 = {new SqlParameter("@StartTime",StartTime)
                                 ,new SqlParameter("@EndTime",EndTime)
                                  };
            ds4 = DbHelperSQL.ExecProc("uspEmp3ReportD4", para4);
            ReportDataSource rds4 = new ReportDataSource();
            rds4.Name = "DataSet4";
            rds4.Value = ds4.Tables[0];
            localReport.DataSources.Add(rds4);

            //按课程类型分组
            DataSet ds5 = new DataSet();
            SqlParameter[] para5 = {new SqlParameter("@StartTime",StartTime)
                                 ,new SqlParameter("@EndTime",EndTime)
                                  };
            ds5 = DbHelperSQL.ExecProc("uspEmp3ReportD5", para5);
            ReportDataSource rds5 = new ReportDataSource();
            rds5.Name = "DataSet5";
            rds5.Value = ds5.Tables[0];
            localReport.DataSources.Add(rds5);

            //按课程名称分组
            DataSet ds6 = new DataSet();
            SqlParameter[] para6 = {new SqlParameter("@StartTime",StartTime)
                                 ,new SqlParameter("@EndTime",EndTime)
                                  };
            ds6 = DbHelperSQL.ExecProc("uspEmp3ReportD6", para6);
            ReportDataSource rds6 = new ReportDataSource();
            rds6.Name = "DataSet6";
            rds6.Value = ds6.Tables[0];
            localReport.DataSources.Add(rds6);

            //按导师类型分组
            DataSet ds7 = new DataSet();
            SqlParameter[] para7 = {new SqlParameter("@StartTime",StartTime)
                                 ,new SqlParameter("@EndTime",EndTime)
                                  };
            ds7 = DbHelperSQL.ExecProc("uspEmp3ReportD7", para7);
            ReportDataSource rds7 = new ReportDataSource();
            rds7.Name = "DataSet7";
            rds7.Value = ds7.Tables[0];
            localReport.DataSources.Add(rds7);

            //按导师姓名分组
            DataSet ds8 = new DataSet();
            SqlParameter[] para8 = {new SqlParameter("@StartTime",StartTime)
                                 ,new SqlParameter("@EndTime",EndTime)
                                  };
            ds8 = DbHelperSQL.ExecProc("uspEmp3ReportD8", para8);
            ReportDataSource rds8 = new ReportDataSource();
            rds8.Name = "DataSet8";
            rds8.Value = ds8.Tables[0];
            localReport.DataSources.Add(rds8);

            //按开课时间分组
            DataSet ds9 = new DataSet();
            SqlParameter[] para9 = {new SqlParameter("@StartTime",StartTime)
                                 ,new SqlParameter("@EndTime",EndTime)
                                  };
            ds9 = DbHelperSQL.ExecProc("uspEmp3ReportD9", para9);
            ReportDataSource rds9 = new ReportDataSource();
            rds9.Name = "DataSet9";
            rds9.Value = ds9.Tables[0];
            localReport.DataSources.Add(rds9);

            //按部门分组
            DataSet ds10 = new DataSet();
            SqlParameter[] para10 = {new SqlParameter("@StartTime",StartTime)
                                 ,new SqlParameter("@EndTime",EndTime)
                                  };
            ds10 = DbHelperSQL.ExecProc("uspEmp3ReportD10", para10);
            ReportDataSource rds10 = new ReportDataSource();
            rds10.Name = "DataSet10";
            rds10.Value = ds10.Tables[0];
            localReport.DataSources.Add(rds10);

            //按品牌分组
            DataSet ds11 = new DataSet();
            SqlParameter[] para11 = {new SqlParameter("@StartTime",StartTime)
                                 ,new SqlParameter("@EndTime",EndTime)
                                  };
            ds11 = DbHelperSQL.ExecProc("uspEmp3ReportD11", para11);
            ReportDataSource rds11 = new ReportDataSource();
            rds11.Name = "DataSet11";
            rds11.Value = ds11.Tables[0];
            localReport.DataSources.Add(rds11);

            ReportViewer1.LocalReport.Refresh();

        }
        catch (Exception ex)
        {

            throw;
        }
    }
}